package zjc.案例练习;

import java.util.Scanner;

public class 评委打分 {
    public static void main(String[] args) {
        Scanner sr=new Scanner(System.in);
        double[]a=new double[6];
        for (int i = 0; i < 6; i++) {
            System.out.println("输入第"+(i+1)+"个评委的分数");
            a[i]=sr.nextDouble();
        }
        double sum=sum(a);
        System.out.println("最高分是"+max(a));
        System.out.println("最低分是"+min(a));
        System.out.println("除去一个最高分和一个最低分后的平均值：");
        System.out.println((sum-max(a)-min(a))*1.0/(a.length+2));
    }
    public static double max(double[]a){
        int max=0;
        for (int i = 1; i < a.length; i++) {
            if(a[i]>a[max]){
                max=i;
            }
        }
        return a[max];
    }
    public static double min(double[]a){
        int min=0;
        for (int i = 1; i < a.length; i++) {
            if(a[i]<a[min]){
                min=i;
            }
        }
        return a[min];
    }
    public static double sum(double[]a){
        double s=0;
        for (int i = 0; i < a.length; i++) {
            s+=a[i];
        }
        return s;
    }

}
